/**
 * @class Ext.app.Home
 * @extends Object
 * Main layout application class.
 */

Ext.define('Ext.app.Home', {
    extend: 'Ext.container.Viewport',
    
    requires: [
        "Ext.app.DanhSachPhieuNhapKhoPanel",
        'Ext.app.PhieuNhapKhoPanel',
        'Ext.app.LoaiHangHoaPanel'
    ],

    constructor: function (translations, functions) {
        this.translations = translations;
        this.functions = functions;
        
        this.callParent(arguments);
    },
    
    initComponent: function() {
        Ext.apply(this, {
            id: 'app-viewport',
            layout: {
                type: 'border',
                padding: '5 5 5 5' // pad the layout from the window edges
            },
            items: [                            
            {
                xtype: 'toolbar',
                region: 'north',
                items: [
                {
                    text : this.translations.get("HOME.MAT_HANG"),
                    menu: {
                        items: [
                            {
                                text: this.translations.get("HOME.LOAI_HANG_HOA"),
                                handler: function() {
                                    displayPanel({
                                        xtype: 'loaiHangHoaPanel',
                                        title: translations.get("HOME.LOAI_HANG_HOA_TITLE")
                                    });
                                }
                            },
                            {
                                text: this.translations.get("HOME.DANH_SACH_MAT_HANG"),
                                handler: danhSachMatHang
                            }
                        ]
                    }
                },
                '-',
                {
                    text : this.translations.get("HOME.BAN_HANG"),
                    menu: {
                        items: [
                            {
                                text: this.translations.get("HOME.NHAP_PHIEU_BAN_HANG"),
                                handler: lapPhieuBanHang
                            },
                            {
                                text: this.translations.get("HOME.DS_PHIEU_BAN_HANG"),
                                handler: danhSachPhieuBanHang
                            }
                        ]
                    }
                },
                '-',
                {
                    text : this.translations.get("HOME.QUAN_LY_KHO"),
                    menu: {
                        items: [
                            /*{
                                text: this.translations.get("HOME.DANH_SACH_KHO"),
                                handler: function() {
                                    displayPanel({
                                        xtype: 'danhSachKhoPanel',
                                        title: translations.get("HOME.DANH_SACH_KHO_TITLE")
                                    });
                                }
                            },*/
                            {
                                text: this.translations.get("HOME.DANH_SACH_PHIEU_NHAP_KHO"),
                                handler: function() {
                                    displayPanel({
                                        xtype: 'danhSachPhieuNhapKhoPanel',
                                        title: translations.get("HOME.DANH_SACH_PHIEU_NHAP_KHO_TITLE")
                                    });
                                }
                            },
                            {
                                text: this.translations.get("HOME.NHAP_KHO"),
                                handler: function() {
                                    displayPanel({
                                        xtype: 'phieuNhapKhoPanel',
                                        title: translations.get("HOME.PHIEU_NHAP_KHO_TITLE")
                                    });
                                }
                            }/*,
                            {
                                text: this.translations.get("HOME.XUAT_KHO"),
                                handler: xuatKho
                            }*/
                        ]
                    }
                }]
            },
            {
                id: 'appMainPanel',
                xtype: 'container',
                region: 'center',
                layout: 'border',
                padding: '10 0 0 0',
                items: [{
                    xtype: 'panel',
                    region: 'center',
                    html: '<table style="width:100%;height:100%" border="0"><tr><td align="center"><img src="images/logo.jpg" border="0"/></td></tr></table>'
                }]
            }]
        });
        this.callParent(arguments);
    }
});
